#include <stdio.h>
#include <iostream>
using namespace std;
    int movingCount(int threshold, int rows, int cols)
    {
        if(threshold < 0 ||rows <= 0 || cols <= 0)
        {
            return 0;
        }
        int i = rows;
        int j = cols;
        int num2 = 0;
        int ret = 0;
        for(i = 0; i < rows; ++i)
        {
            
          if(i%2 == 0)
          {
            for(j = 0; j < cols; ++j)
            {
              num2 = 0;
              int tmp = i;
              while(tmp)
              {
                num2 += tmp%10;
                tmp /= 10;
              }

              tmp = j;
              while(tmp)
              {
                num2 += tmp%10;
                tmp  /= 10;
              }

              if(num2 <= threshold )
              {
                ret++;
              }
            }

          }
          else
          {
            for(j = cols - 1; j >= 0; --j)
            {
              num2 = 0;
              int tmp = i;
              while(tmp)
              {
                num2 += tmp%10;
                tmp /= 10;
              }

              tmp = j;
              while(tmp)
              {
                num2 += tmp%10;
                tmp  /= 10;
              }

              if(num2 <= threshold )
              {
                ret++;
              }
            }

          }
        }
        return ret;
    }

int main()
{
  int ret = movingCount(10, 1, 100);
  printf("ret :%d\n",ret);

  return 0;
}
